<template>
  <div>
    <ul id="special_content">
      <li
        v-for="(item, index) in news"
        :key="index"
        @click="gotonewsdetails(item)"
      >
        <img :src="item.pic" alt="" />
        <p>{{ item.title }}</p>
        <p>{{ item.descript }}</p>
        <p>查看详情</p>
      </li>
    </ul>
  </div>
</template>
<script>
export default {
  data() {
    return {
      news: [],
    };
  },
  mounted() {
    this.$API.getNews().then((res) => {
      console.log(res.data.data);
      this.news = res.data.data;
    });
  },
  methods: {
    gotonewsdetails(item) {
      this.$router.push({ path: "/newsdetails", 
      query: {
           id: item.id
        } 
    });
    },
  },
};
</script>
<style lang="scss" scope>
#special_content {
  padding-top: 0.7rem;
  padding-bottom: 0.2rem;
  li {
    padding: 0.1rem;
    text-align: center;
    position: relative;
    img {
      width: 100%;
      height: 12rem;
      display: block;
      background: rgba(0, 0, 0, 0.7);
    }
    p:nth-of-type(1) {
      position: absolute;
      top: 0.6rem;
      left: 10%;
      width: 80%;
      text-align: center;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
      font-size: 1rem;
      color: white;
    }
    p:nth-of-type(2) {
      position: absolute;
      top: 3rem;
      left: 10%;
      width: 80%;
      text-align: center;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
      font-size: 0.8rem;
      color: white;
    }
    p:nth-of-type(3) {
      position: absolute;
      top: 5rem;
      left: 7.8rem;
      width: 20%;
      height: 2rem;
      text-align: center;
      line-height: 2rem;
      font-size: 0.18rem;
      color: white;
      border: 0.01rem solid #ffffff;
      border-radius: 0.5rem;
    }
    
  }
}
</style>